package address

import (
	"errors"

	"gitee.com/xgotool/backend-framework-template/config"
	"gitee.com/xgotool/backend-framework-template/model"
)

// 获取地址详情信息
//
//	id	地址ID
func Info(id uint) (*model.Address, error) {
	mod := model.Address{}
	conn, err := config.GetConnect()
	if err != nil {
		return nil, err
	}
	err = conn.Table(mod.TableName()).
		Where("id", id).
		Where("is_deleted", 0).
		Omit("is_deleted", "updated_at").
		Find(&mod).
		Error
	if err != nil {
		return nil, err
	}
	if mod.Id == 0 {
		return nil, errors.New("地址不存在/已删除")
	}
	return &mod, nil
}
